//
//  HNSH_OrderListHeader.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/3/3.
//

#import "HNSH_OrderListHeader.h"

@interface HNSH_OrderListHeader ()

/* bgView */
@property (nonatomic, strong) UIView *bgView;

/* shopNameLabel */
@property (nonatomic, strong) UILabel *shopNameLabel;
/* statusLabel */
@property (nonatomic, strong) UILabel *statusLabel;

/* lineView */
@property (nonatomic, strong) UIView *lineView;

@end

@implementation HNSH_OrderListHeader

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        [self configUI];
    }
    return self;
}

- (void)setModel:(HNSH_OrderListModel *)model {
    _model = model;
    
    self.shopNameLabel.text = model.shop_name;
    //
    NSAttributedString * status = [[NSAttributedString alloc] initWithData:[model.order_status_text dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil];
    self.statusLabel.attributedText = status;
    self.statusLabel.textAlignment = NSTextAlignmentRight;
}

- (void)configUI {
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.shopNameLabel];
    [self.bgView addSubview:self.statusLabel];
    [self.bgView addSubview:self.lineView];
}


#pragma mark lazy
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc]initWithFrame:CGRectMake(20, 20, kScreenWidth-40, 68)];
        _bgView.backgroundColor = [UIColor appWhiteLabelColor];
        [self clipCornerWithView:_bgView cornerWidth:10 cornerType:UIRectCornerTopLeft|UIRectCornerTopRight];
    }
    return _bgView;
}

- (UILabel *)shopNameLabel {
    if (!_shopNameLabel) {
        _shopNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(8, 16, 150, 22)];
        _shopNameLabel.text = @"";
        _shopNameLabel.textColor = [UIColor appBlackLabelColor];
        _shopNameLabel.font = [UIFont boldSystemFontOfSize:16];
    }
    return _shopNameLabel;
}

- (UILabel *)statusLabel {
    if (!_statusLabel) {
        _statusLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth-48-150, 16, 150, 22)];
        _statusLabel.text = @"";
        _statusLabel.textColor = [UIColor appGreenColor];
        _statusLabel.font = [UIFont boldSystemFontOfSize:14];
        _statusLabel.textAlignment = NSTextAlignmentRight;
    }
    return _statusLabel;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(11, 49, kScreenWidth-62, 1)];
        _lineView.backgroundColor = [UIColor colorWithHexString:@"#EDEDED"];
    }
    return _lineView;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
